﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;

namespace Drifting.Graphics.PhysicalObjects.Vehicles
{
    public class Z4 : PhysicalObject
    {

        public Z4(Game1 game)
        {
            Body = game.Content.Load<Model>("models\\Z4\\Z4");
            Body_AbsoluteMatrix = new Matrix[Body.Bones.Count];
            Body.CopyAbsoluteBoneTransformsTo(Body_AbsoluteMatrix);

            body_scale = 0.997f;
            m_calibration = Matrix.CreateTranslation(2.145f, 0, 0.9752f);
        }

        public void Draw(Matrix camera, Matrix projection, float q_x, float q_y, float q_t, float steeringAngle)
        {
            Matrix config = Matrix.CreateRotationY(q_t) *
                            Matrix.CreateTranslation(q_x, 0, -q_y);

            foreach (ModelMesh mesh in Body.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    effect.EnableDefaultLighting();
                    effect.View = camera;
                    effect.Projection = projection;
                    effect.World =

                        Body_AbsoluteMatrix[mesh.ParentBone.Index] *

                        Matrix.CreateScale(body_scale) *

                        m_calibration *

                        config;
                }
                mesh.Draw();
            }
        }
    }
}
